package My.example;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

@WebServlet(urlPatterns  ={"/demo2"})
public class serve1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String get=req.getMethod();
        System.out.println(get);

        String p=req.getContextPath();
        System.out.println(p);

        String uri=req.getRequestURI();
        System.out.println(uri);

        StringBuffer sb=req.getRequestURL();
        System.out.println(sb.toString());

        String q=req.getQueryString();
        System.out.println(q);

        String ag=req.getHeader("User-Agent");
        System.out.println(ag);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BufferedReader s=req.getReader();
        String line=null;
        line=s.readLine();
        System.out.println(line);
    }
}
